define(['FormClear'],function(){
	//文本框提示
	var InputTips={
		bind:function(){
			var inputSelector='input[type="text"],input[type="password"],textarea';
			$('body').on('focus',inputSelector,function(){
				var $this=$(this);
				if($this.value()=='' && !$this.attr('readonly')){
					$this.val('');
					$this.addClass('focus');
					pwdTipsCtrl($this,'hide');
				}
			})
			$('body').on('blur',inputSelector,function(){
				var $this=$(this);
				if($this.value()!=''){
				 	$this.addClass('focus');
					pwdTipsCtrl($this,'hide');
				}else{
					FormClear($this);
				}
			})
		},
		focus:function($groupDom){
			if($groupDom==undefined){
				$groupDom=$('body');
			}
			$groupDom.find('[data-tips]').each(function(){
				var $this=$(this);
				if($this.value()!=''){
					$this.addClass('focus');
				}
			})
		}
	}
	function pwdTipsCtrl($this,mode){
		var $thisPrev=$this.prev();
		if($this.attr('type')!='password'){
			return false;
		}
		if($thisPrev.hasClass('inputTips')){
			switch (mode){
				case 'show':
					$thisPrev.css({
						'color':''
					})
					break;
				case 'hide':
					$thisPrev.css({
						'color':'transparent'
					})
					break;
			}

		}
	}
	window.InputTips=InputTips;
	InputTips.bind();
	requireLoad.ready(function(){
		InputTips.focus();
	});
	return InputTips;
})
